import urllib2
from BeautifulSoup import BeautifulSoup

site = "Facebook"
url = "http://www.facebook.com/home.php"
domains = ["facebook.com"]
sessionCookieNames = ['xs','c_user','sid']

def identifyUser(site,session):
  try:
    cookies = ''.join([k+"="+session.cookies[k]+";" for k in session.cookies])
    req = urllib2.Request(site.url,headers={'Cookie':cookies,'User-Agent':'Firefox/3.6.3'})
    html = urllib2.urlopen(req).read()
    soup = BeautifulSoup(html)
    session.userName = soup.find(attrs={"id":"navAccountName"}).findAll(text=True)[0]
  except:
    pass

